package indi.liangli;

import indi.liangli.discovery.IServiceDiscovery;
import indi.liangli.discovery.ServiceDisCoveryZkImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

@Component
public class RpcConsumer {
    @Autowired
    private IServiceDiscovery serviceDiscovery;


    public <T> T clientProxy(Class<T> clazz,final String ip,final int port){
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new RemoteProxyInvocationHandler(serviceDiscovery));
    }


}
